<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<lu id="id"></lu>

<script>
  var data = [
    {
      "children": [
        {
          "children": [
            {
              "children": [],
              "icon": "1",
              "name": "团队查询",
              "id": 3,
              "parentId": 2,
              "url": "/user/z",
              "menuSort": 3
            },
            {
              "children": [],
              "icon": "1",
              "name": "团队管理",
              "id": 4,
              "parentId": 2,
              "url": "/user/z",
              "menuSort": 4
            },
            {
              "children": [],
              "icon": "1",
              "name": "综拓团队申请",
              "id": 5,
              "parentId": 2,
              "url": "/user/z",
              "menuSort": 5
            }
          ],
          "icon": "1",
          "name": "销售团队",
          "id": 2,
          "parentId": 1,
          "url": "/user/z",
          "menuSort": 2
        },
        {
          "children": [
            {
              "children": [],
              "icon": "1",
              "name": "销售人员查询",
              "id": 7,
              "parentId": 6,
              "url": "/user/z",
              "menuSort": 1
            },
            {
              "children": [],
              "icon": "1",
              "name": "销售人员管理",
              "id": 8,
              "parentId": 6,
              "url": "/user/z",
              "menuSort": 2
            },
            {
              "children": [],
              "icon": "1",
              "name": "考试管理",
              "id": 9,
              "parentId": 6,
              "url": "/user/z",
              "menuSort": 3
            },
            {
              "children": [],
              "icon": "1",
              "name": "手动清分",
              "id": 10,
              "parentId": 6,
              "url": "/user/z",
              "menuSort": 4
            }
          ],
          "icon": "1",
          "name": "销售人员",
          "id": 6,
          "parentId": 1,
          "url": "/user/z",
          "menuSort": 2
        }
      ],
      "icon": "1",
      "name": "综合岗",
      "id": 1,
      "parentId": 0,
      "url": "/user/z",
      "menuSort": 1
    },
    {
      "children": [
        {
          "children": [
            {
              "children": [],
              "icon": "1",
              "name": "团队审批",
              "id": 14,
              "parentId": 12,
              "url": "/user/z",
              "menuSort": 1
            }
          ],
          "icon": "1",
          "name": "销售团队",
          "id": 12,
          "parentId": 11,
          "url": "/user/z",
          "menuSort": 1
        },
        {
          "children": [
            {
              "children": [],
              "icon": "1",
              "name": "人员审批",
              "id": 15,
              "parentId": 13,
              "url": "/user/z",
              "menuSort": 1
            }
          ],
          "icon": "1",
          "name": "销售人员",
          "id": 13,
          "parentId": 11,
          "url": "/user/z",
          "menuSort": 2
        }
      ],
      "icon": "1",
      "name": "管理岗",
      "id": 11,
      "parentId": 0,
      "url": "/user/z",
      "menuSort": 2
    }
  ]

  var cont = ''
  for (var i = 0; i < data.length; i++) {
    cont = cont + p(data[i])
  }
  document.getElementById('id').innerHTML = cont

  function p(data) {
    var html = '<li><a href="javascript:;">' + data.name + '</a>'
    if (data.children.length > 0) {
      console.log(data.children)
      html = html + c(data.children)
    }
    return html + '</li>'
  }

  function c(children) {
    var html = '<lu>'
    for (var j = 0; j < children.length; j++) {
      html = html + p(children[j])
    }
    return html + '</lu>'
  }
</script>

</body>
</html>
